<template>
    <div class="home">
        <van-button type="info" size="large" color="#FFF" @click="login">登录</van-button>
        <div>
            <p>用户名:{{userInfo.name}}</p>
            <p>id:{{userInfo.id}}</p>
        </div>
    </div>
</template>
<script>
import { login } from "../api/Interface";
import { mapGetters, mapActions } from "vuex";
export default {
    name: "home",
    comments: {},
    data() {
        return {};
    },
    computed: {
        ...mapGetters("user", {
            userInfo: "getUserInfo"
        })
    },
    methods: {
        ...mapActions("user", ["setUserInfo"]),
        login: function() {
            login({ name: "123444", password: "123456" })
                .then(res => {
                    this.setUserInfo(res.data);
                })
                .catch(err => {
                    // console.log(err);
                });
        }
    }
};
</script>
<style lang="scss" scoped>
</style>
